using System;
using System.Collections.Generic;
using System.Text;
using MindFactorial.LaunchPoint.Common;

namespace MindFactorial.LaunchPoint.Runtime
{
    /// <summary>
    /// Represents an IPC Object that remains in the memory for the life time of an application
    /// and option to set Life time delegate and raises an event when .
    /// </summary>
    public class RunnableComponentLifetimeManager : ImmortalIPCObject
    {
        /// <summary>
        /// fires when the application is exiting
        /// </summary>
        LifetimeEventHandler _exited = null;

        

        /// <summary>
        /// Default Constructor
        /// </summary>
        public RunnableComponentLifetimeManager()
        {
           
        }

        /// <summary>
        /// Raises LifetimeEventHandler Event
        /// </summary>
        /// <param name="appid"> Application ID</param>
        public void Exited(string appid)
        {
            _exited(appid);
        }

        /// <summary>
        /// Sets Life time delegate
        /// </summary>
        /// <param name="exit"></param>
        public void SetLifetimeDelegates(LifetimeEventHandler exit)
        {
            _exited = exit;            
        }

    }
}
